//
//  HYLRedView.m
//  拖view
//
//  Created by hyl on 16/6/13.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "HYLRedView.h"

@implementation HYLRedView

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    NSLog(@"%s",__func__);
}

-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //NSLog(@"%@",event);
    NSLog(@"%@",touches);
    UITouch *touch=[touches anyObject];
    //CGFloat xMove=[touch locationInView:self].x-[touch preciseLocationInView:self].x;
    //CGFloat hMove=[touch locationInView:self].y-[touch preciseLocationInView:self].y;
    CGPoint curP=[touch locationInView:self];
//    CGPoint prep=[touch preciseLocationInView:self]; 9.0之前
    CGPoint preP=[touch precisePreviousLocationInView:self];//9.0之后
    CGFloat offsetX=curP.x-preP.x;
    CGFloat offsetY=curP.y-preP.y;
    NSLog(@"%f  %f",curP.x,preP.x);
    //NSLog(@"%f,%f",offsetX ,offsetY);
    self.transform=CGAffineTransformTranslate(self.transform, offsetX, offsetY);
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
